package com.example.sesata.controller;

import com.example.sesata.domain.CommonResult;
import com.example.sesata.service.StorageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chensixiang chensixiang1234@gmail.com
 */
@RestController
@RequiredArgsConstructor
@Slf4j
public class StorageController {

    private final StorageService storageService;


    @PutMapping("/storage/decrease")
    CommonResult<Object> decrease(@RequestParam("productId") Long productId, @RequestParam("count") Integer count) {
        storageService.decrease(productId, count);
        return new CommonResult<>(200, "扣减库存成功");
    }

}
